import turtle
import math

# 设置画布和画笔
screen = turtle.Screen()
screen.title("红色的花")
screen.bgcolor("white")

flower = turtle.Turtle()
flower.speed(10)  # 绘制速度，1-10递增，0为最快
flower.color("red")
flower.fillcolor("red")

# 定义绘制花瓣的函数
def draw_petal(radius, angle):
    flower.begin_fill()
    # 绘制花瓣的曲线
    for _ in range(2):
        flower.circle(radius, angle)
        flower.left(180 - angle)
    flower.end_fill()

# 绘制花蕊
flower.penup()
flower.goto(0, -20)
flower.pendown()
flower.color("yellow")
flower.fillcolor("yellow")
flower.begin_fill()
flower.circle(20)
flower.end_fill()

# 绘制花瓣（12个花瓣）
flower.color("red")
flower.fillcolor("red")
petal_count = 12
angle = 360 / petal_count

for _ in range(petal_count):
    draw_petal(100, 60)  # 花瓣大小和角度
    flower.left(angle)

# 绘制花茎
flower.penup()
flower.goto(0, -20)
flower.pendown()
flower.color("green")
flower.pensize(3)
flower.setheading(270)  # 向下
flower.forward(150)

# 绘制叶子
def draw_leaf(size):
    flower.begin_fill()
    flower.circle(size, 60)
    flower.left(120)
    flower.circle(size, 60)
    flower.end_fill()

# 左边叶子
flower.setheading(220)
draw_leaf(40)

# 右边叶子
flower.penup()
flower.goto(0, -170)
flower.pendown()
flower.setheading(320)
draw_leaf(40)

# 隐藏画笔并保持窗口
flower.hideturtle()
screen.mainloop()
